﻿// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "BaseCharacter.h"
#include "InputMappingContext.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "Actor/BaseWeapon.h"
// #include "GameMode/CombatGameMode.h"
#include "PlayerCharacter.generated.h"

class ACombatGameMode;
UCLASS()
class COMBAT_GAME_CPP_API APlayerCharacter : public ABaseCharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	APlayerCharacter();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

	//********************************************************* component组件
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Component")
	USpringArmComponent* CameraBoom;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Component")
	UCameraComponent* FollowCamera;

	//********************************************************* 增强输入
	// input
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
	UInputMappingContext* InputMappingContext;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
	UInputAction* MoveAction;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
	UInputAction* LookAction;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
	UInputAction* JumpAction;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
	UInputAction* ChangeAttackAction;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
	UInputAction* PlayAttackAction;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
	UInputAction* GamePauseAction;

	// input function
	void Move(const FInputActionValue& Value);

	void Look(const FInputActionValue& Value);

	void JumpFunction(const FInputActionValue& Value);

	void ChangeAttack(const FInputActionValue& Value);

	void PlayAttack(const FInputActionValue& Value);

	void GamePause(const FInputActionValue& Value);


	//********************************************************* 初始化
	void RegistInputContext();

	void SpawnWeapon();


	//********************************************************* 成员变量属性

	UPROPERTY(BlueprintReadWrite)
	ACombatGameMode* GameMode;
	
	// 是否攻击状态	用于判断动画蓝图的状态切换
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
	bool IsAttackState_Anim;

	// 选择武器类
	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	TSubclassOf<ABaseWeapon> SelectWeapon;

	// 武器实例
	UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
	ABaseWeapon* Weapon;

	// 卸载武器的蒙太奇动画
	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	UAnimMontage* UnEquipMontage;

	// 装备武器的蒙太奇动画
	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	UAnimMontage* EquipMontage;

	// 技能的蒙太奇动画
	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	TArray<UAnimMontage*> AttackMontages;

	//*********************************************** 抽象实现

	UFUNCTION(BlueprintCallable)
	virtual void AttackDamage() override;

	UFUNCTION(BlueprintCallable)
	virtual void TakeHitDamage(const float DamageValue) override;

	//	重写一下伤害响应
	virtual void HurtResponse() override;

	UFUNCTION(BlueprintCallable)
	virtual void DeathClear() override;


	void StopOperation();

	void StartOperation();
};
